#-------------------------------------------------------------------------------
#	file Makefile
#
#	brief
#		Makefile: Decawave DecaDriver library (libdeca.a)
#
#	$Id: Makefile 295 2014-09-02 05:20:45Z ac.verbeck@gmail.com $
#-------------------------------------------------------------------------------

#-------------------------------------------------------------------------------
#	The MIT License (MIT)
#	
#	Copyright (c) 2014 A.C. Verbeck
#	
#	Permission is hereby granted, free of charge, to any person obtaining a copy
#	of this software and associated documentation files (the "Software"), to deal
#	in the Software without restriction, including without limitation the rights
#	to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
#	copies of the Software, and to permit persons to whom the Software is
#	furnished to do so, subject to the following conditions:
#
#	The above copyright notice and this permission notice shall be included in
#	all copies or substantial portions of the Software.

#	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
#	IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
#	FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
#	AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
#	LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
#	OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
#	THE SOFTWARE.
#-------------------------------------------------------------------------------

#-------------------------------------------------------------------------------
#	Pattern rules
#-------------------------------------------------------------------------------
%.o: %.c
	@echo making: $@ | sed 's/\(.*\).o/\1/'
	@$(CC) -c $(CFLAGS) $(CPPFLAGS) -o $@ $<

#-------------------------------------------------------------------------------
#	Environment
#-------------------------------------------------------------------------------
CC			= arm-none-eabi-gcc
AR			= arm-none-eabi-ar

C_FLAGS		= -fmessage-length=0 -Wextra -std=gnu11
C_ARCH		= -mcpu=cortex-m3 -mthumb -fsigned-char -ffunction-sections -fdata-sections -ffreestanding
C_DEFINES	= -DEBUG -DUSE_FULL_ASSERT -DTRACE -DOS_USE_TRACE_ITM -DSTM32F10X_CL -DUSE_STDPERIPH_DRIVER -DHSE_VALUE=12000000
C_INC_CMSIS	= -I"../system/include" -I"../system/include/cmsis" -I"../system/include/stm32f1-stdperiph"
C_INC_DECA	= -I"../compiler" -I"../decadriver" -I"../platform" -I"../sys"
CFLAGS		= $(C_FLAGS) $(C_ARCH) $(C_DEFINES) $(C_INC_CMSIS) $(C_INC_DECA)

#-------------------------------------------------------------------------------
#	Targets
#-------------------------------------------------------------------------------
TARGET		= libdeca.a

#-------------------------------------------------------------------------------
#	Rules
#-------------------------------------------------------------------------------
.PHONY:	all clean format install

all:		$(TARGET)

clean:;		$(RM) *.o
			$(RM) *.bak
			$(RM) *.c.orig
			$(RM) *.h.orig
			$(RM) $(TARGET)

format:;	astyle --style="k&r" --indent=tab --lineend=windows --recursive "*.c" "*.h"

install:;	cp $(TARGET) ~/bin

#-------------------------------------------------------------------------------
#	Dependencies
#-------------------------------------------------------------------------------
$(TARGET):	deca_device.o deca_params_init.o deca_range_tables.o
			$(AR) -q $(TARGET) *.o

#
#	End: Makefile
#
